﻿using System;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using HslCommunication.BasicFramework;
using HslCommunication.Core;
using HslCommunication.Core.IMessage;
using HslCommunication.Core.Net;
using HslCommunication.LogNet;
using HslCommunication.Reflection;

namespace HslCommunication.Profinet.Omron
{
	/// <summary>
	/// <b>[商业授权]</b> 欧姆龙的虚拟服务器，支持DM区，CIO区，Work区，Hold区，Auxiliary区，可以方便的进行测试<br />
	/// <b>[Authorization]</b> Omron's virtual server supports DM area, CIO area, Work area, Hold area, and Auxiliary area, which can be easily tested
	/// </summary>
	// Token: 0x0200005C RID: 92
	public class OmronFinsServer : NetworkDataServerBase
	{
		/// <summary>
		/// 实例化一个Fins协议的服务器<br />
		/// Instantiate a Fins protocol server
		/// </summary>
		// Token: 0x060007A1 RID: 1953 RVA: 0x000284C8 File Offset: 0x000266C8
		public OmronFinsServer()
		{
			this.dBuffer = new SoftBuffer(131072);
			this.cioBuffer = new SoftBuffer(131072);
			this.wBuffer = new SoftBuffer(131072);
			this.hBuffer = new SoftBuffer(131072);
			this.arBuffer = new SoftBuffer(131072);
			this.dBuffer.IsBoolReverseByWord = true;
			this.cioBuffer.IsBoolReverseByWord = true;
			this.wBuffer.IsBoolReverseByWord = true;
			this.hBuffer.IsBoolReverseByWord = true;
			this.arBuffer.IsBoolReverseByWord = true;
			base.WordLength = 1;
			base.ByteTransform = new ReverseWordTransform();
			base.ByteTransform.DataFormat = DataFormat.CDAB;
		}

		/// <inheritdoc cref="P:HslCommunication.Core.ByteTransformBase.DataFormat" />
		// Token: 0x1700015D RID: 349
		// (get) Token: 0x060007A2 RID: 1954 RVA: 0x00028597 File Offset: 0x00026797
		// (set) Token: 0x060007A3 RID: 1955 RVA: 0x000285A4 File Offset: 0x000267A4
		public DataFormat DataFormat
		{
			get
			{
				return base.ByteTransform.DataFormat;
			}
			set
			{
				base.ByteTransform.DataFormat = value;
			}
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Omron.OmronFinsNet.Read(System.String,System.UInt16)" />
		// Token: 0x060007A4 RID: 1956 RVA: 0x000285B4 File Offset: 0x000267B4
		[HslMqttApi("ReadByteArray", "")]
		public override OperateResult<byte[]> Read(string address, ushort length)
		{
			OperateResult<OmronFinsDataType, byte[]> operateResult = OmronFinsNetHelper.AnalysisAddress(address, false);
			bool flag = !operateResult.IsSuccess;
			OperateResult<byte[]> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<byte[]>(operateResult);
			}
			else
			{
				bool flag2 = operateResult.Content1.WordCode == OmronFinsDataType.DM.WordCode;
				if (flag2)
				{
					result = OperateResult.CreateSuccessResult<byte[]>(this.dBuffer.GetBytes(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2, (int)(length * 2)));
				}
				else
				{
					bool flag3 = operateResult.Content1.WordCode == OmronFinsDataType.CIO.WordCode;
					if (flag3)
					{
						result = OperateResult.CreateSuccessResult<byte[]>(this.cioBuffer.GetBytes(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2, (int)(length * 2)));
					}
					else
					{
						bool flag4 = operateResult.Content1.WordCode == OmronFinsDataType.WR.WordCode;
						if (flag4)
						{
							result = OperateResult.CreateSuccessResult<byte[]>(this.wBuffer.GetBytes(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2, (int)(length * 2)));
						}
						else
						{
							bool flag5 = operateResult.Content1.WordCode == OmronFinsDataType.HR.WordCode;
							if (flag5)
							{
								result = OperateResult.CreateSuccessResult<byte[]>(this.hBuffer.GetBytes(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2, (int)(length * 2)));
							}
							else
							{
								bool flag6 = operateResult.Content1.WordCode == OmronFinsDataType.AR.WordCode;
								if (flag6)
								{
									result = OperateResult.CreateSuccessResult<byte[]>(this.arBuffer.GetBytes(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2, (int)(length * 2)));
								}
								else
								{
									result = new OperateResult<byte[]>(StringResources.Language.NotSupportedFunction);
								}
							}
						}
					}
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Omron.OmronFinsNet.Write(System.String,System.Byte[])" />
		// Token: 0x060007A5 RID: 1957 RVA: 0x0002877C File Offset: 0x0002697C
		[HslMqttApi("WriteByteArray", "")]
		public override OperateResult Write(string address, byte[] value)
		{
			OperateResult<OmronFinsDataType, byte[]> operateResult = OmronFinsNetHelper.AnalysisAddress(address, false);
			bool flag = !operateResult.IsSuccess;
			OperateResult result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<byte[]>(operateResult);
			}
			else
			{
				bool flag2 = operateResult.Content1.WordCode == OmronFinsDataType.DM.WordCode;
				if (flag2)
				{
					this.dBuffer.SetBytes(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2);
				}
				else
				{
					bool flag3 = operateResult.Content1.WordCode == OmronFinsDataType.CIO.WordCode;
					if (flag3)
					{
						this.cioBuffer.SetBytes(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2);
					}
					else
					{
						bool flag4 = operateResult.Content1.WordCode == OmronFinsDataType.WR.WordCode;
						if (flag4)
						{
							this.wBuffer.SetBytes(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2);
						}
						else
						{
							bool flag5 = operateResult.Content1.WordCode == OmronFinsDataType.HR.WordCode;
							if (flag5)
							{
								this.hBuffer.SetBytes(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2);
							}
							else
							{
								bool flag6 = operateResult.Content1.WordCode == OmronFinsDataType.AR.WordCode;
								if (!flag6)
								{
									return new OperateResult(StringResources.Language.NotSupportedFunction);
								}
								this.arBuffer.SetBytes(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 2);
							}
						}
					}
				}
				result = OperateResult.CreateSuccessResult();
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Omron.OmronFinsNet.ReadBool(System.String,System.UInt16)" />
		// Token: 0x060007A6 RID: 1958 RVA: 0x00028928 File Offset: 0x00026B28
		[HslMqttApi("ReadBoolArray", "")]
		public override OperateResult<bool[]> ReadBool(string address, ushort length)
		{
			OperateResult<OmronFinsDataType, byte[]> operateResult = OmronFinsNetHelper.AnalysisAddress(address, true);
			bool flag = !operateResult.IsSuccess;
			OperateResult<bool[]> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<bool[]>(operateResult);
			}
			else
			{
				bool flag2 = operateResult.Content1.BitCode == OmronFinsDataType.DM.BitCode;
				if (flag2)
				{
					result = OperateResult.CreateSuccessResult<bool[]>(this.dBuffer.GetBool(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2], (int)length));
				}
				else
				{
					bool flag3 = operateResult.Content1.BitCode == OmronFinsDataType.CIO.BitCode;
					if (flag3)
					{
						result = OperateResult.CreateSuccessResult<bool[]>(this.cioBuffer.GetBool(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2], (int)length));
					}
					else
					{
						bool flag4 = operateResult.Content1.BitCode == OmronFinsDataType.WR.BitCode;
						if (flag4)
						{
							result = OperateResult.CreateSuccessResult<bool[]>(this.wBuffer.GetBool(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2], (int)length));
						}
						else
						{
							bool flag5 = operateResult.Content1.BitCode == OmronFinsDataType.HR.BitCode;
							if (flag5)
							{
								result = OperateResult.CreateSuccessResult<bool[]>(this.hBuffer.GetBool(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2], (int)length));
							}
							else
							{
								bool flag6 = operateResult.Content1.BitCode == OmronFinsDataType.AR.BitCode;
								if (flag6)
								{
									result = OperateResult.CreateSuccessResult<bool[]>(this.arBuffer.GetBool(((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2], (int)length));
								}
								else
								{
									result = new OperateResult<bool[]>(StringResources.Language.NotSupportedFunction);
								}
							}
						}
					}
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Omron.OmronFinsNet.Write(System.String,System.Boolean[])" />
		// Token: 0x060007A7 RID: 1959 RVA: 0x00028B18 File Offset: 0x00026D18
		[HslMqttApi("WriteBoolArray", "")]
		public override OperateResult Write(string address, bool[] value)
		{
			OperateResult<OmronFinsDataType, byte[]> operateResult = OmronFinsNetHelper.AnalysisAddress(address, true);
			bool flag = !operateResult.IsSuccess;
			OperateResult result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<bool[]>(operateResult);
			}
			else
			{
				bool flag2 = operateResult.Content1.BitCode == OmronFinsDataType.DM.BitCode;
				if (flag2)
				{
					this.dBuffer.SetBool(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2]);
				}
				else
				{
					bool flag3 = operateResult.Content1.BitCode == OmronFinsDataType.CIO.BitCode;
					if (flag3)
					{
						this.cioBuffer.SetBool(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2]);
					}
					else
					{
						bool flag4 = operateResult.Content1.BitCode == OmronFinsDataType.WR.BitCode;
						if (flag4)
						{
							this.wBuffer.SetBool(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2]);
						}
						else
						{
							bool flag5 = operateResult.Content1.BitCode == OmronFinsDataType.HR.BitCode;
							if (flag5)
							{
								this.hBuffer.SetBool(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2]);
							}
							else
							{
								bool flag6 = operateResult.Content1.BitCode == OmronFinsDataType.AR.BitCode;
								if (!flag6)
								{
									return new OperateResult(StringResources.Language.NotSupportedFunction);
								}
								this.arBuffer.SetBool(value, ((int)operateResult.Content2[0] * 256 + (int)operateResult.Content2[1]) * 16 + (int)operateResult.Content2[2]);
							}
						}
					}
				}
				result = OperateResult.CreateSuccessResult();
			}
			return result;
		}

		/// <inheritdoc />
		// Token: 0x060007A8 RID: 1960 RVA: 0x00028CF4 File Offset: 0x00026EF4
		protected override void ThreadPoolLoginAfterClientCheck(Socket socket, IPEndPoint endPoint)
		{
			FinsMessage netMessage = new FinsMessage();
			OperateResult<byte[]> operateResult = base.ReceiveByMessage(socket, 5000, netMessage, null);
			bool flag = !operateResult.IsSuccess;
			if (!flag)
			{
				OperateResult operateResult2 = base.Send(socket, SoftBasic.HexStringToBytes("46 49 4E 53 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01"));
				bool flag2 = !operateResult2.IsSuccess;
				if (!flag2)
				{
					AppSession appSession = new AppSession();
					appSession.IpEndPoint = endPoint;
					appSession.WorkSocket = socket;
					try
					{
						socket.BeginReceive(new byte[0], 0, 0, SocketFlags.None, new AsyncCallback(this.SocketAsyncCallBack), appSession);
						base.AddClient(appSession);
					}
					catch
					{
						socket.Close();
						ILogNet logNet = base.LogNet;
						if (logNet != null)
						{
							logNet.WriteDebug(this.ToString(), string.Format(StringResources.Language.ClientOfflineInfo, endPoint));
						}
					}
				}
			}
		}

		// Token: 0x060007A9 RID: 1961 RVA: 0x00028DD4 File Offset: 0x00026FD4
		[DebuggerStepThrough]
		private void SocketAsyncCallBack(IAsyncResult ar)
		{
			OmronFinsServer.<SocketAsyncCallBack>d__9 <SocketAsyncCallBack>d__ = new OmronFinsServer.<SocketAsyncCallBack>d__9();
			<SocketAsyncCallBack>d__.<>t__builder = AsyncVoidMethodBuilder.Create();
			<SocketAsyncCallBack>d__.<>4__this = this;
			<SocketAsyncCallBack>d__.ar = ar;
			<SocketAsyncCallBack>d__.<>1__state = -1;
			<SocketAsyncCallBack>d__.<>t__builder.Start<OmronFinsServer.<SocketAsyncCallBack>d__9>(ref <SocketAsyncCallBack>d__);
		}

		/// <summary>
		/// 当收到mc协议的报文的时候应该触发的方法，允许继承重写，来实现自定义的返回，或是数据监听。<br />
		/// The method that should be triggered when a message of the mc protocol is received is allowed to be inherited and rewritten to achieve a custom return or data monitoring.
		/// </summary>
		/// <param name="finsCore">mc报文</param>
		/// <returns>返回的报文信息</returns>
		// Token: 0x060007AA RID: 1962 RVA: 0x00028E14 File Offset: 0x00027014
		protected virtual byte[] ReadFromFinsCore(byte[] finsCore)
		{
			bool flag = finsCore[this.headLength + 10] == 1 && finsCore[this.headLength + 11] == 1;
			byte[] result;
			if (flag)
			{
				result = this.PackCommand(this.ReadByCommand(SoftBasic.ArrayRemoveBegin<byte>(finsCore, this.headLength + 10)));
			}
			else
			{
				bool flag2 = finsCore[this.headLength + 10] == 1 && finsCore[this.headLength + 11] == 2;
				if (flag2)
				{
					result = this.PackCommand(this.WriteByMessage(SoftBasic.ArrayRemoveBegin<byte>(finsCore, this.headLength + 10)));
				}
				else
				{
					result = null;
				}
			}
			return result;
		}

		/// <summary>
		/// 将核心报文打包的方法，追加报文头<br />
		/// The method of packing the core message, adding the message header
		/// </summary>
		/// <param name="data">核心的内容</param>
		/// <returns>完整的报文信息</returns>
		// Token: 0x060007AB RID: 1963 RVA: 0x00028EAC File Offset: 0x000270AC
		protected virtual byte[] PackCommand(byte[] data)
		{
			byte[] array = new byte[30 + data.Length];
			SoftBasic.HexStringToBytes("46 49 4E 53 00 00 00 0000 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00").CopyTo(array, 0);
			bool flag = data.Length != 0;
			if (flag)
			{
				data.CopyTo(array, 30);
			}
			byte[] bytes = BitConverter.GetBytes(array.Length - 8);
			Array.Reverse(bytes);
			bytes.CopyTo(array, 4);
			return array;
		}

		// Token: 0x060007AC RID: 1964 RVA: 0x00028F0C File Offset: 0x0002710C
		private byte[] ReadByCommand(byte[] command)
		{
			bool flag = command[2] == OmronFinsDataType.DM.BitCode || command[2] == OmronFinsDataType.CIO.BitCode || command[2] == OmronFinsDataType.WR.BitCode || command[2] == OmronFinsDataType.HR.BitCode || command[2] == OmronFinsDataType.AR.BitCode;
			byte[] result;
			if (flag)
			{
				ushort length = (ushort)((int)command[6] * 256 + (int)command[7]);
				int destIndex = ((int)command[3] * 256 + (int)command[4]) * 16 + (int)command[5];
				bool flag2 = command[2] == OmronFinsDataType.DM.BitCode;
				if (flag2)
				{
					result = Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(this.dBuffer.GetBool(destIndex, (int)length), (bool m) => m ? 1 : 0));
				}
				else
				{
					bool flag3 = command[2] == OmronFinsDataType.CIO.BitCode;
					if (flag3)
					{
						result = Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(this.cioBuffer.GetBool(destIndex, (int)length), (bool m) => m ? 1 : 0));
					}
					else
					{
						bool flag4 = command[2] == OmronFinsDataType.WR.BitCode;
						if (flag4)
						{
							result = Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(this.wBuffer.GetBool(destIndex, (int)length), (bool m) => m ? 1 : 0));
						}
						else
						{
							bool flag5 = command[2] == OmronFinsDataType.HR.BitCode;
							if (flag5)
							{
								result = Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(this.hBuffer.GetBool(destIndex, (int)length), (bool m) => m ? 1 : 0));
							}
							else
							{
								bool flag6 = command[2] == OmronFinsDataType.AR.BitCode;
								if (!flag6)
								{
									throw new Exception(StringResources.Language.NotSupportedDataType);
								}
								result = Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(this.arBuffer.GetBool(destIndex, (int)length), (bool m) => m ? 1 : 0));
							}
						}
					}
				}
			}
			else
			{
				bool flag7 = command[2] == OmronFinsDataType.DM.WordCode || command[2] == OmronFinsDataType.CIO.WordCode || command[2] == OmronFinsDataType.WR.WordCode || command[2] == OmronFinsDataType.HR.WordCode || command[2] == OmronFinsDataType.AR.WordCode;
				if (flag7)
				{
					ushort num = (ushort)((int)command[6] * 256 + (int)command[7]);
					int num2 = (int)command[3] * 256 + (int)command[4];
					bool flag8 = command[2] == OmronFinsDataType.DM.WordCode;
					if (flag8)
					{
						result = this.dBuffer.GetBytes(num2 * 2, (int)(num * 2));
					}
					else
					{
						bool flag9 = command[2] == OmronFinsDataType.CIO.WordCode;
						if (flag9)
						{
							result = this.cioBuffer.GetBytes(num2 * 2, (int)(num * 2));
						}
						else
						{
							bool flag10 = command[2] == OmronFinsDataType.WR.WordCode;
							if (flag10)
							{
								result = this.wBuffer.GetBytes(num2 * 2, (int)(num * 2));
							}
							else
							{
								bool flag11 = command[2] == OmronFinsDataType.HR.WordCode;
								if (flag11)
								{
									result = this.hBuffer.GetBytes(num2 * 2, (int)(num * 2));
								}
								else
								{
									bool flag12 = command[2] == OmronFinsDataType.AR.WordCode;
									if (!flag12)
									{
										throw new Exception(StringResources.Language.NotSupportedDataType);
									}
									result = this.arBuffer.GetBytes(num2 * 2, (int)(num * 2));
								}
							}
						}
					}
				}
				else
				{
					result = new byte[0];
				}
			}
			return result;
		}

		// Token: 0x060007AD RID: 1965 RVA: 0x000292B4 File Offset: 0x000274B4
		private byte[] WriteByMessage(byte[] command)
		{
			bool flag = command[2] == OmronFinsDataType.DM.BitCode || command[2] == OmronFinsDataType.CIO.BitCode || command[2] == OmronFinsDataType.WR.BitCode || command[2] == OmronFinsDataType.HR.BitCode || command[2] == OmronFinsDataType.AR.BitCode;
			byte[] result;
			if (flag)
			{
				ushort num = (ushort)((int)command[6] * 256 + (int)command[7]);
				int destIndex = ((int)command[3] * 256 + (int)command[4]) * 16 + (int)command[5];
				bool[] value = Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(SoftBasic.ArrayRemoveBegin<byte>(command, 8), (byte m) => m == 1));
				bool flag2 = command[2] == OmronFinsDataType.DM.BitCode;
				if (flag2)
				{
					this.dBuffer.SetBool(value, destIndex);
				}
				else
				{
					bool flag3 = command[2] == OmronFinsDataType.CIO.BitCode;
					if (flag3)
					{
						this.cioBuffer.SetBool(value, destIndex);
					}
					else
					{
						bool flag4 = command[2] == OmronFinsDataType.WR.BitCode;
						if (flag4)
						{
							this.wBuffer.SetBool(value, destIndex);
						}
						else
						{
							bool flag5 = command[2] == OmronFinsDataType.HR.BitCode;
							if (flag5)
							{
								this.hBuffer.SetBool(value, destIndex);
							}
							else
							{
								bool flag6 = command[2] == OmronFinsDataType.AR.BitCode;
								if (!flag6)
								{
									throw new Exception(StringResources.Language.NotSupportedDataType);
								}
								this.arBuffer.SetBool(value, destIndex);
							}
						}
					}
				}
				result = new byte[0];
			}
			else
			{
				ushort num2 = (ushort)((int)command[6] * 256 + (int)command[7]);
				int num3 = (int)command[3] * 256 + (int)command[4];
				byte[] data = SoftBasic.ArrayRemoveBegin<byte>(command, 8);
				bool flag7 = command[2] == OmronFinsDataType.DM.WordCode;
				if (flag7)
				{
					this.dBuffer.SetBytes(data, num3 * 2);
				}
				else
				{
					bool flag8 = command[2] == OmronFinsDataType.CIO.WordCode;
					if (flag8)
					{
						this.cioBuffer.SetBytes(data, num3 * 2);
					}
					else
					{
						bool flag9 = command[2] == OmronFinsDataType.WR.WordCode;
						if (flag9)
						{
							this.wBuffer.SetBytes(data, num3 * 2);
						}
						else
						{
							bool flag10 = command[2] == OmronFinsDataType.HR.WordCode;
							if (flag10)
							{
								this.hBuffer.SetBytes(data, num3 * 2);
							}
							else
							{
								bool flag11 = command[2] == OmronFinsDataType.AR.WordCode;
								if (!flag11)
								{
									throw new Exception(StringResources.Language.NotSupportedDataType);
								}
								this.arBuffer.SetBytes(data, num3 * 2);
							}
						}
					}
				}
				result = new byte[0];
			}
			return result;
		}

		/// <inheritdoc />
		// Token: 0x060007AE RID: 1966 RVA: 0x00029560 File Offset: 0x00027760
		protected override void LoadFromBytes(byte[] content)
		{
			bool flag = content.Length < 786432;
			if (flag)
			{
				throw new Exception("File is not correct");
			}
			this.dBuffer.SetBytes(content, 0, 0, 131072);
			this.cioBuffer.SetBytes(content, 131072, 0, 131072);
			this.wBuffer.SetBytes(content, 262144, 0, 131072);
			this.hBuffer.SetBytes(content, 393216, 0, 131072);
			this.arBuffer.SetBytes(content, 524288, 0, 131072);
			this.arBuffer.SetBytes(content, 655360, 0, 131072);
		}

		/// <inheritdoc />
		// Token: 0x060007AF RID: 1967 RVA: 0x00029614 File Offset: 0x00027814
		protected override byte[] SaveToBytes()
		{
			byte[] array = new byte[786432];
			Array.Copy(this.dBuffer.GetBytes(), 0, array, 0, 131072);
			Array.Copy(this.cioBuffer.GetBytes(), 0, array, 131072, 131072);
			Array.Copy(this.wBuffer.GetBytes(), 0, array, 262144, 131072);
			Array.Copy(this.hBuffer.GetBytes(), 0, array, 393216, 131072);
			Array.Copy(this.arBuffer.GetBytes(), 0, array, 524288, 131072);
			Array.Copy(this.arBuffer.GetBytes(), 0, array, 655360, 131072);
			return array;
		}

		/// <inheritdoc cref="M:System.IDisposable.Dispose" />
		// Token: 0x060007B0 RID: 1968 RVA: 0x000296DC File Offset: 0x000278DC
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				SoftBuffer softBuffer = this.dBuffer;
				if (softBuffer != null)
				{
					softBuffer.Dispose();
				}
				SoftBuffer softBuffer2 = this.cioBuffer;
				if (softBuffer2 != null)
				{
					softBuffer2.Dispose();
				}
				SoftBuffer softBuffer3 = this.wBuffer;
				if (softBuffer3 != null)
				{
					softBuffer3.Dispose();
				}
				SoftBuffer softBuffer4 = this.hBuffer;
				if (softBuffer4 != null)
				{
					softBuffer4.Dispose();
				}
				SoftBuffer softBuffer5 = this.arBuffer;
				if (softBuffer5 != null)
				{
					softBuffer5.Dispose();
				}
			}
			base.Dispose(disposing);
		}

		/// <inheritdoc />
		// Token: 0x060007B1 RID: 1969 RVA: 0x00029753 File Offset: 0x00027953
		public override string ToString()
		{
			return string.Format("OmronFinsServer[{0}]", base.Port);
		}

		// Token: 0x040001E8 RID: 488
		private SoftBuffer dBuffer;

		// Token: 0x040001E9 RID: 489
		private SoftBuffer cioBuffer;

		// Token: 0x040001EA RID: 490
		private SoftBuffer wBuffer;

		// Token: 0x040001EB RID: 491
		private SoftBuffer hBuffer;

		// Token: 0x040001EC RID: 492
		private SoftBuffer arBuffer;

		// Token: 0x040001ED RID: 493
		private const int DataPoolLength = 65536;

		/// <summary>
		/// 头部命令的长度，用来在tcp协议和udp协议传输的时候区别
		/// </summary>
		// Token: 0x040001EE RID: 494
		protected int headLength = 16;
	}
}
